#ifndef HISTORY_H
#define HISTORY_H

#include <QtWidgets>
#include "qcustomplot.h"
#include "globalval.h"

namespace Ui {
class History;
}

class History : public QWidget
{
    Q_OBJECT

public:
    explicit History(QWidget *parent = 0);
    ~History();
protected:
    void paintEvent(QPaintEvent *event);
private slots:
    void updateData();
private:
    Ui::History *ui;
    QTimer *timer;
    QVector<QPointF> temperatureData;   // 温度数据
    QVector<QPointF> humidityData;      // 湿度数据
    QVector<QPointF> lightData;// 光照强度数据

   int temperature; // 温度初始值
   int humidity; // 湿度初始值
   int lightIntensity; // 光照强度初始值

   int minValue = 0;
   int maxValue = 100;
   int minTime = 0;
   int maxTime = 100;

   int margin = 20;

   // 绘制坐标轴
       void drawAxes(QPainter *painter);

       // 绘制曲线
       void drawCurve(QPainter *painter, const QVector<QPointF>& data, const QColor& color);
};

#endif // HISTORY_H
